/**
 * SEVAS - Swiss Electronic Vaccination Advisor Service / Agile Development
 *
 * $Id: Application.java 29 2010-08-18 16:51:14Z zimmr7@bfh.ch $
 */
package ch.bfh.sevas.gui;

import ch.bfh.sevas.Controller;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.application.SingleFrameApplication;

public class ElectronicVaccinationCard extends SingleFrameApplication {

    @Override
    protected void startup() {
        try {
            LoginDialog dialog = new LoginDialog(null, true);
            dialog.setLocationRelativeTo(null); dialog.setVisible(true);
            if (dialog.getReturnStatus() == LoginDialog.RET_CANCEL) {
                System.exit(0);
            }
            Controller controller = new Controller();
            if (controller.validateUserAuthentication(dialog.getUsername(), dialog.getPassword()) == null)
                System.exit(0); else show(new VaccinationCardView(this, controller));
        } catch (Exception ex) {
            Logger.getLogger(ElectronicVaccinationCard.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @Override
    protected void configureWindow(java.awt.Window root) {
    }

    public static ElectronicVaccinationCard getApplication() {
        return ElectronicVaccinationCard.getInstance(ElectronicVaccinationCard.class);
    }

    public static void main(String[] args) {
        launch(ElectronicVaccinationCard.class, args);
    }
}
